<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>BOOST_TEST_NO_MAIN</title>
<link rel="stylesheet" href="../../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Boost.Test">
<link rel="up" href="../link_references.html" title="Build scenarios and behaviors">
<link rel="prev" href="link_boost_test_dyn_link.html" title="BOOST_TEST_DYN_LINK">
<link rel="next" href="link_boost_test_global_configuration.html" title="BOOST_TEST_GLOBAL_CONFIGURATION">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="link_boost_test_dyn_link.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../link_references.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="link_boost_test_global_configuration.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="boost_test.utf_reference.link_references.link_boost_test_no_main"></a><a class="link" href="link_boost_test_no_main.html" title="BOOST_TEST_NO_MAIN"><code class="computeroutput"><span class="identifier">BOOST_TEST_NO_MAIN</span></code></a>
</h4></div></div></div>
<p>
          Prevents the auto generation of the test module initialization functions.
          This macro is particularly relevant for manually registered tests in conjunction
          with dynamic variant of the <span class="emphasis"><em>Unit Test Framework</em></span>. When
          defined, a <code class="computeroutput"><span class="identifier">main</span></code> function
          registering all the tests should be implemented.
        </p>
<p>
          An example of a module initialization would be
        </p>
<pre class="programlisting"><span class="preprocessor">#define</span> <a class="link" href="link_boost_test_no_main.html" title="BOOST_TEST_NO_MAIN"><code class="computeroutput"><span class="identifier">BOOST_TEST_NO_MAIN</span></code></a>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">test</span><span class="special">/</span><span class="identifier">unit_test</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="comment">// a function in another compilation unit registering tests under the master test suite.</span>
<span class="keyword">void</span> <span class="identifier">register_some_tests_manually</span><span class="special">(</span><span class="identifier">test_suite</span><span class="special">*</span> <span class="identifier">test</span><span class="special">);</span>

<span class="keyword">bool</span> <span class="identifier">registering_all_tests</span><span class="special">()</span>
<span class="special">{</span>
  <span class="identifier">test_suite</span><span class="special">*</span> <span class="identifier">test_master_suite</span> <span class="special">=</span> <span class="special">&amp;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">unit_test</span><span class="special">::</span><span class="identifier">framework</span><span class="special">::</span><span class="identifier">master_test_suite</span><span class="special">();</span>
  <span class="identifier">register_some_tests_manually</span><span class="special">(</span><span class="identifier">test_master_suite</span><span class="special">);</span>

  <span class="comment">// register any other tests function or test suite to the master test suite</span>
  <span class="comment">// ...</span>
  <span class="keyword">return</span> <span class="keyword">true</span><span class="special">;</span>
<span class="special">}</span>

<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">argc</span><span class="special">,</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">argv</span><span class="special">[])</span>
<span class="special">{</span>
  <span class="keyword">return</span> <span class="special">::</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">unit_test</span><span class="special">::</span><span class="identifier">unit_test_main</span><span class="special">(&amp;</span><span class="identifier">registering_all_tests</span><span class="special">,</span> <span class="identifier">argc</span><span class="special">,</span> <span class="identifier">argv</span><span class="special">);</span>
<span class="special">}</span>
</pre>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2001-2022 Boost.Test contributors<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="link_boost_test_dyn_link.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../link_references.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="link_boost_test_global_configuration.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
